home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Combine zero-offset with unit-offset arrays ?
- Date: 4 Mar 1996 10:00:31 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hfb3vINNmlg@keats.ugrad.cs.ubc.ca>
- References: <4hes0h$52qi@info4.rus.uni-stuttgart.de> <4hfau5INNme5@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4hfau5INNme5@keats.ugrad.cs.ubc.ca>,
- Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- >#define fa(x) (fa[x-1])
- >{
- > int foo = fa(1);
- >}
-
- By the way, that should be
-
- #define fa(x) (fa[(x)-1])
-
- since there are many expressions with lower precedence than -, but higher than
- comma, such as shift and and bitwise logic operators.
-
- >which now gives you fa[1-1], which is *((fa) + 1 - 1). This is defined. The
- >standard allows you generate a pointer which references one element past the
- >end of the array, thus if you put in the subscript 10, you would have
- >*((fa) + 10 - 1). ANSI condones the generation of a pointer to the non-existant
- >element of the array that is conceptually one index past the last one, in
- >order to support certain common coding idioms.
- >--
- >
-
-
- --
-
-